package com.hyf.translucentstatusbar.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hyf.translucentstatusbar.entity.MainItem;

import java.util.List;

/**
 * Created by Administrator on 2017/9/8.
 */

public class MainListViewAdapater extends BaseAdapter {
    private List<MainItem> mList;

    private Activity mActivity;

    private LayoutInflater mInflater;

    public MainListViewAdapater(List<MainItem> list, Activity activity) {
        mList = list;
        mActivity = activity;
        mInflater = LayoutInflater.from(mActivity);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        TextView textView = (TextView) mInflater.inflate(android.R.layout.simple_list_item_1, null);
        textView.setText(mList.get(i).getTitle());
        textView.setOnClickListener(mList.get(i).getListener());
        return textView;
    }
}
